<template>
	<div class="signIn w944">
		<alert ref="alert"></alert>
		<div class="label_top">
			<button @click="reBack"><i><&nbsp;</i>返回</button>
			<p>报名管理——{{lectureName}}</p>
		</div>
		<div class="label_table">
			<div class="el-tabs-report">
				<a class="listOne" @click="importDaoChu">导出数据</a>
			</div>
			<el-table ref="multipleTable" :data="tableData" border>
				<el-table-column prop="no" label="编号"></el-table-column>
				<el-table-column prop="realname" label="报名者"></el-table-column>
				<el-table-column prop="phone" label="手机号"></el-table-column>
				<el-table-column prop="idcard" label="身份证"></el-table-column>
				<el-table-column prop="email" label="邮箱"></el-table-column>
			</el-table>
			<div class="fenyeMargin">
				<div class="pag_block">
					<el-pagination @current-change="handleCurrentChange" :current-page="currentpage" :page-size="pagesize" layout="prev, pager, next" :total="total"></el-pagination>
				</div>
			</div>
		</div>
	</div>
</template>
<script>
	import alert from '../../components/Alert.vue';
	export default {
		data() {
			return {
				lectureId:'', //课程编号id
				lectureName:'', //课程名称
		        pagesize: 15,
		        currentpage: 1,
		        total: 1,
				id:'',
				tableData: [],
				tableChecked:[],
				ids:[],
				multipleSelection: [],
			}
		},
		methods: {
			getParams() {
				this.lectureId = this.$route.params.lectureId;
				this.lectureName = this.$route.params.lectureName
			},
			getCommentsList(){
				this.$ajax({
					url: this.$root.jifuUrl + "/getActivityLectureUserPage?"+'page='+this.currentpage+'&num='+this.pagesize+'&lectureid='+this.lectureId,
					method: 'GET',
					data: {},
					success: res => {
						if(res.data.code == 200) {
							this.tableData = res.data.data.list;
							this.total=res.data.data.pageParam.items;
						}
					}
				});
			},
			importDaoChu(){
				this.axios({
			        url: this.$root.jifuUrl + "/exportActivityLectureUserInfo?"+'lectureid='+this.lectureId,
			        headers: {Authorization:this.$root.userInfoMsg.sessionId},
			        method: 'POST',
			        responseType: 'blob'
			    }).then((res) => {
			        var blob = new Blob([res], {type: 'application/vnd.ms-excel;charset=utf-8'})
                    var downloadElement = document.createElement('a');
                    var href = window.URL.createObjectURL(blob); //创建下载的链接
                    downloadElement.href = href;
                    downloadElement.download = '导出文件.xls'; //下载后文件名
                    document.body.appendChild(downloadElement);
                    downloadElement.click(); //点击下载
                    document.body.removeChild(downloadElement); //下载完成移除元素
                    window.URL.revokeObjectURL(href); //释放掉blob对象
			    }).catch(error => {
			       	this.failText = res.data.message;
					this.$rootFunction().deleteResFail();
			    })
			},
			handleCurrentChange(value) {
				this.currentpage = value;
				this.getTableList();
			},
			reBack(){
				this.$router.go(-1);
			}
		},
		components:{
			alert
		},
		mounted: function() {
			this.getParams();
			if(this.lectureId==null||this.lectureName==null){
				this.$store.commit('GET_lectureSignIn');
				var s =this.$store.state.lectureSign;
				console.log('GET_lectureSignIn',s)
				this.lectureId=s.lectureId,
				this.lectureName=s.lectureName;
			}
			this.getCommentsList();
			window.addEventListener("beforeunload",()=>{
				s={
					lectureId : this.lectureId,
					lectureName:this.lectureName
				}	
				this.$store.commit('SET_lectureSignIn', s);
			});
		}
	}
</script>

<style>
	.signIn .file{background:#fff!important;height:33px;line-height:33px;width:60px!important;display:inline-block;color:#44cef6!important;text-align:center;border-radius:5px;cursor:pointer;outline:none;border:none;position:relative;*display:inline;cursor:pointer;margin-left: 10px;}
	.signIn .file input{height:33px;line-height:33px;width:60px;position:absolute;font-size:100px;right:0;top:0;opacity:0;
	filter:alpha(opacity=0);cursor:pointer;overflow: hidden;}
</style>